package com.its.classOrder.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.its.classOrder.mapper.ClassOrderMapper;
import com.its.classOrder.pojo.ClassOrder;
import com.its.classOrder.service.ClassOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author lenovo
* @description 针对表【gym_class_order】的数据库操作Service实现
* @createDate 2025-04-22 23:47:58
*/
@Service
public class ClassOrderServiceImpl extends ServiceImpl<ClassOrderMapper, ClassOrder> implements ClassOrderService {
    //依赖注入Mapper层属性
    @Autowired
    private ClassOrderMapper classOrderMapper;

    //添加报名信息
    @Override
    public int addClassOrder(ClassOrder classOrder) {
        return classOrderMapper.insert(classOrder);
    }

    //删除报名表信息
    @Override
    public int deleteClassOrder(Integer classOrderId) {
        return classOrderMapper.deleteById(classOrderId);
    }

    //更新报名表信息
    @Override
    public int updateClassOrder(ClassOrder classOrder) {
        return classOrderMapper.updateById(classOrder);
    }

    //根据会员账户名查询报名表信息
    @Override
    public List<ClassOrder> selectClassOrderByMemberAccount(Integer memberAccount) {
        QueryWrapper<ClassOrder> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("member_account",memberAccount);
        return classOrderMapper.selectList(queryWrapper);
    }

    //根据课程ID查寻会员报名表信息
    @Override
    public ClassOrder selectMemberOrderByClassId(Integer classId) {
        return classOrderMapper.selectById(classId);
    }

    //分页查询所有报名表信息
    @Override
    public Page<ClassOrder> selectAllClassOrder(Integer page, Integer size) {
        return classOrderMapper.selectPage(new Page<>(page,size),null);
    }
}




